package demo4;

import java.util.Scanner;

// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        char[] s = in.next().toCharArray();
        int x = in.nextInt();
        int begin = 0;//结果串的起始下标
        int maxCount = 0; //统计之前窗口内C+G的最大值
        int left = 0, right = 0,n = s.length;
        int count = 0; //统计窗口内C+G的值
        while (right < n) {
            if(s[right] == 'C' || s[right] == 'G') {
                count++;
            }

            while (right - left + 1 > x) {
                if(s[left] == 'C' || s[left] == 'G') {
                    count--;
                }
                left++;
            }

            if(right - left + 1 == x) {
                if(count > maxCount) {
                    begin = left;
                    maxCount = count;
                }
            }

            right++;
        }

        for(int i = begin; i<begin+x; i++) {
            System.out.print(s[i]);
        }
    }
}